package logic

import (
	"context"

	"gitcode.com/sunsungk9/opensource-demo-cockroachdb-obs-241123/user/internal/svc"
	"gitcode.com/sunsungk9/opensource-demo-cockroachdb-obs-241123/user/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type DropLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDropLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DropLogic {
	return &DropLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DropLogic) Drop() (resp *types.Response, err error) {
	// drop user table
	_, err = l.svcCtx.DB.Exec("DROP TABLE `users`")
	if err != nil {
		return
	}
	resp = new(types.Response)
	resp.Message = "success"
	return
}
